import { faker } from '@faker-js/faker';

import { BasicStatus, PermissionType } from '#/enum';

/**
 * Organization data mock
 */
export const ORG_LIST = [
  {
    id: '1',
    name: 'East China Branch',
    status: 'enable',
    desc: faker.lorem.words(),
    sortOrder: 1,
    children: [
      { id: '1-1', name: 'R&D Department', status: 'disable', desc: '', sortOrder: 1 },
      { id: '1-2', name: 'Marketing Department', status: 'enable', desc: '', sortOrder: 2 },
      { id: '1-3', name: 'Finance Department', status: 'enable', desc: '', sortOrder: 3 },
    ],
  },
  {
    id: '2',
    name: 'South China Branch',
    status: 'enable',
    desc: faker.lorem.words(),
    sortOrder: 2,
    children: [
      { id: '2-1', name: 'R&D Department', status: 'disable', desc: '', sortOrder: 1 },
      { id: '2-2', name: 'Marketing Department', status: 'enable', desc: '', sortOrder: 2 },
      { id: '2-3', name: 'Finance Department', status: 'enable', desc: '', sortOrder: 3 },
    ],
  },
];

/**
 * User permission mock
 */
const DASHBOARD_PERMISSION = {
  id: '9100714781927703',
  parentId: '',
  sortOrder: 1,
  label: 'sys.menu.dashboard',
  name: 'Dashboard',
  icon: 'ic-analysis',
  type: PermissionType.CATALOGUE,
  route: 'dashboard',
  permission: null, // TODO: 新增加权限字段 需要适配
  children: [
    {
      id: '8426999229400979',
      parentId: '9100714781927703',
      label: 'sys.menu.workbench',
      name: 'Workbench',
      sortOrder: 1,
      type: PermissionType.MENU,
      route: 'workbench',
      component: '/dashboard/workbench/index.tsx',
    },
  ],
};
const MANAGEMENT_PERMISSION = {
  id: '0901673425580518',
  parentId: '',
  label: 'sys.menu.management',
  name: 'Management',
  icon: 'ic-management',
  type: PermissionType.CATALOGUE,
  route: 'management',
  sortOrder: 2,
  children: [
    {
      id: '0249937641030250',
      parentId: '0901673425580518',
      label: 'sys.menu.system.index',
      name: 'System',
      type: PermissionType.CATALOGUE,
      route: 'system',
      children: [
        {
          id: '4359580910369984',
          parentId: '0249937641030250',
          label: 'sys.menu.system.permission',
          name: 'Permission',
          type: PermissionType.MENU,
          route: 'permission',
          component: '/management/system/permission/index.tsx',
        },
        {
          id: '1689241785490759',
          parentId: '0249937641030250',
          label: 'sys.menu.system.role',
          name: 'Role',
          type: PermissionType.MENU,
          route: 'role',
          component: '/management/system/role/index.tsx',
        },
        {
          id: '0157880245365433',
          parentId: '0249937641030250',
          label: 'sys.menu.system.user',
          name: 'User',
          type: PermissionType.MENU,
          route: 'user',
          component: '/management/system/user/index.tsx',
        },
        {
          id: '0157880245365434',
          parentId: '0249937641030250',
          label: 'sys.menu.system.user_detail',
          name: 'User Detail',
          type: PermissionType.MENU,
          route: 'user/:id',
          component: '/management/system/user/detail.tsx',
          hide: true,
        },
      ],
    },
  ],
};

const OTHERS_PERMISSION = [
  {
    id: '5455837930804461',
    parentId: '',
    label: 'sys.menu.disabled',
    name: 'Disabled',
    icon: 'ic_disabled',
    type: PermissionType.MENU,
    route: 'disabled',
    status: BasicStatus.DISABLE,
    component: '/sys/others/calendar/index.tsx',
  },
  {
    id: '7728048658221587',
    parentId: '',
    label: 'sys.menu.label',
    name: 'Label',
    icon: 'ic_label',
    type: PermissionType.MENU,
    route: 'label',
    newFeature: true,
    component: '/sys/others/blank.tsx',
  },
];

export const PERMISSION_LIST = [DASHBOARD_PERMISSION, MANAGEMENT_PERMISSION, ...OTHERS_PERMISSION];

/**
 * User role mock
 */
const ADMIN_ROLE = {
  id: '4281707933534332',
  name: 'Admin',
  label: 'admin',
  status: BasicStatus.ENABLE,
  sortOrder: 1,
  desc: 'Super Admin',
  permission: PERMISSION_LIST,
};
const TEST_ROLE = {
  id: '9931665660771476',
  name: 'Test',
  label: 'test',
  status: BasicStatus.ENABLE,
  sortOrder: 2,
  desc: 'test',
  permission: [DASHBOARD_PERMISSION],
};
export const ROLE_LIST = [ADMIN_ROLE, TEST_ROLE];

/**
 * User data mock
 */
export const DEFAULT_USER = {
  id: 'b34719e1-ce46-457e-9575-99505ecee828',
  account: 'tgzs',
  email: faker.internet.email(),
  // avatar: faker.image.avatarLegacy(),
  avatar: '',
  createdAt: faker.date.anytime(),
  updatedAt: faker.date.recent(),
  password: 'tgzs',
  role: ADMIN_ROLE,
  permissions: ADMIN_ROLE.permission,
};

const userMsg = {
  tokenName: 'token',
  tokenValue: '34d6e9cb-759c-4405-8c5e-ccb942703668',
  isLogin: true,
  loginId: 'tgzs',
  loginType: 'admin',
  tokenTimeout: 86392,
  sessionTimeout: 86392,
  tokenSessionTimeout: -2,
  tokenActiveTimeout: -1,
  loginDevice: 'default-device',
  tag: null,
};

export const USER_LIST = [DEFAULT_USER];
